CodeModelMacros Sample: Demonstrates How to Use the Code Model Functions

This sample is a collection of macros that use the Code Model to perform useful tasks. The macros included are:

Security Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

Installing and Running the Sample

To install the macros

  1. Copy the file CodeModelMacros.vsmacros to your hard drive.

  2. Start Visual Studio.

  3. From the Tools menu, point to Macros and then click Macro Explorer. This will open the Macro Explorer window.

  4. From the Tools menu, point to Macros and then click Load Macro Project. This will open the Add Macro Project dialog box.

  5. Browse to the CodeModelMacros.vsmacros file and click the Open button. This action will load the macros file and the macros will appear in the Macro Explorer.

  6. Expand the CodeModelMacros node. You will see one module for each macro.

To execute HierarchyGenerator

  1. Expand the HierarchyGenerator node in the Macro Explorer.

  2. Double-click the HierarchyGenerator macro. This will execute the macro and add an HTML file to the first project in your solution.

To execute InterfaceDocGenerator

  1. Expand the InterfaceDocGenerator node in the Macro Explorer.

  2. Double-click the InterfaceDocGenerator macro. This will execute the macro and add an HTML file to the first project in your solution.

To execute UserTypeGenerator

  1. Expand the UserTypeGenerator node in the Macro Explorer.

  2. Double-click the UsertypeC macro. This will execute the macro and will create a usertype.dat file in the root directory of your C: drive.

To execute VirtualFunctionFinder

  1. Expand the VirtualFunctionFinder node in the Macro Explorer.

  2. Double-click the MainVirtualFunctionFinder macro. This will execute the macro and will add a TODO comment to the virtual functions declared in your project.

Keywords

This sample demonstrates the following keywords:

CodeClass::Members; CodeElement.CodeTypeFromFullName; CodeElement::Children; CodeElement::FullName; CodeElement::Kind; CodeFunction::CanOverride; CodeFunction::Comment; CodeFunction::InfoLocation; CodeFunction::Name; CodeInterface::Name; CodeModel::CodeElements; CodeModel::Language; CodeNamespace::Members; CodeStruct::Members; CodeType::Bases; Project::CodeModel; Solution::Count; VCCodeBase::FullName; VCCodeBase::Name; VCCodeClass::Functions; VCCodeClass::ImplementedInterfaces; VCCodeClass::IsSelf; VCCodeClass::Name; VCCodeFunction::Attributes; VCCodeFunction::Comment; VCCodeFunction::IsVirtual; VCCodeInterface::Functions; VCCodeModel::Classes; VCCodeModel::Interfaces